﻿@model LanLordz.Models.CreatePollModel
@{
    ViewBag.Title = "Create a Poll";
}
@section headers
{
  <script type="text/javascript">
   //<![CDATA[
   var responses = @Math.Max(5, Model.Responses.Count);

   $(document).ready(function(){
    $("#AddResponseDiv").show();
   });

   function AddResponse() {
    responses++;
    $("#ResponseList").append("<input name=\"Response" + responses + "\" type=\"text\" /><br/>");
   }
   //]]>
  </script>
}
    <h2>@ViewBag.Title</h2>
    @using (Html.BeginForm())
    {
     @Html.AntiForgeryToken()
     @Html.ValidationSummary("There was an error creating your poll:", new { @class = "ErrorText" })
     <table class="CreatePollTable">
      <tr><td>Title:</td><td>@Html.TextBox("Title", Model.Title, new { @class = "CreatePollTitleBox" }) (60 Character Limit)</td></tr>
      <tr><td>Description:</td><td>@Html.TextArea("Description", Model.Description, new { @class = "CreatPollDescriptionBox" })</td>
      <tr><td>Options:</td>
       <td>
        @Html.CheckBox("IsPrivate", Model.IsPrivate) @Html.Label("IsPrivate", "Private (Answers visible to you and Administrators only)")<br/>
        @Html.CheckBox("IsMultiAnswer", Model.IsMultiAnswer) @Html.Label("IsMultiAnswer", "Multiple Answers Allowed")
       </td>
      </tr>
      <tr>
       <td>Respones:</td>
       <td id="ResponseList">
       @{
         int modelCount = Model.Responses.Count;
         int count = Math.Max(5, modelCount);
         for (int i = 1; i <= count; i++)
         {
             @Html.TextBox("Response" + i, i <= modelCount ? Model.Responses[i - 1] : "")
             if (i == 1)
             {
                 <text> (60 Character Limit)</text>
             }
             <br/>
         }
       }
       </td>
      </tr>
      <tr><td></td><td><div style="display : none" id="AddResponseDiv"><button onclick="AddResponse(); return false;">Add</button></div><noscript>Enable JavaScript to add more responses.</noscript></td></tr>
      <tr><td></td><td><input type="submit" value="Create" /></td></tr>
     </table>
    }
